CameraDevice Class

Description

CameraDevice实现了一个camera设备,输出 InputFrame (包含图像、摄像机参数和时间戳)。在Windows、Mac、Android和iOS上可用。

打开之后,可以调用start/stop来开始和停止采集数据。start/stop不会影响之前所设置的camera参数。

当不再需要该设备时,可以调用close对其进行关闭。close之后不应继续使用。

CameraDevice通过inputFrameSource输出 InputFrame ,应将inputFrameSource连接到 InputFrameSink 上进行使用。参考 概览 _ 。

bufferCapacity表示 InputFrame 缓冲的容量,如果有超过此数量的 InputFrame 从该设备中输出并且没有被释放,该设备将不再输出新的 InputFrame ,直到之前的 InputFrame 被释放。这可能造成画面卡住等问题。参考 概览 _ 。

Constructor

C: void easyar_CameraDevice__ctor(easyar_CameraDevice * * Return)
C++17: CameraDevice()
Traditional C++: CameraDevice()
Java: public CameraDevice()
Kotlin: constructor()
Objective-C: + (easyar_CameraDevice *) create
Swift: public convenience init()
C#: public CameraDevice()

isAvailable

检查是否可用。只在Windows、Mac、Android和iOS上返回true。

C: bool easyar_CameraDevice_isAvailable(void)
C++17: static bool isAvailable()
Traditional C++: static bool isAvailable()
Java: public static boolean isAvailable()
Kotlin: companion object fun isAvailable(): Boolean
Objective-C: + (bool)isAvailable
Swift: public static func isAvailable() -> Bool
C#: public static bool isAvailable()

androidCameraApiType

在Android上,可用于获得使用的Camera API(camera1或camera2)。camera1兼容性较好,但缺乏一些必要的信息,如时间戳。camera2在部分设备上存在兼容性问题。

C: easyar_AndroidCameraApiType easyar_CameraDevice_androidCameraApiType(easyar_CameraDevice * This)
C++17: AndroidCameraApiType androidCameraApiType()
Traditional C++: AndroidCameraApiType androidCameraApiType()
Java: public int androidCameraApiType()
Kotlin: fun androidCameraApiType(): Int
Objective-C: - (easyar_AndroidCameraApiType)androidCameraApiType
Swift: public func androidCameraApiType() -> AndroidCameraApiType
C#: public virtual AndroidCameraApiType androidCameraApiType()

setAndroidCameraApiType

在Android上,可用于设置使用的Camera API(Camera 1或Camera 2)。必须在调用openWithIndex、openWithSpecificType或openWithPreferredType之前进行设置,否则不会生效。

推荐使用 CameraDeviceSelector 以根据使用的主要算法来创建设好推荐Camera API的CameraDevice。

C: void easyar_CameraDevice_setAndroidCameraApiType(easyar_CameraDevice * This, easyar_AndroidCameraApiType type)
C++17: void setAndroidCameraApiType(AndroidCameraApiType type)
Traditional C++: void setAndroidCameraApiType(AndroidCameraApiType type)
Java: public void setAndroidCameraApiType(int type)
Kotlin: fun setAndroidCameraApiType(type: Int): Unit
Objective-C: - (void)setAndroidCameraApiType:(easyar_AndroidCameraApiType)type
Swift: public func setAndroidCameraApiType(_ type: AndroidCameraApiType) -> Void
C#: public virtual void setAndroidCameraApiType(AndroidCameraApiType type)

bufferCapacity

InputFrame 缓冲的容量,默认值为8。

C: int easyar_CameraDevice_bufferCapacity(const easyar_CameraDevice * This)
C++17: int bufferCapacity()
Traditional C++: int bufferCapacity()
Java: public int bufferCapacity()
Kotlin: fun bufferCapacity(): Int
Objective-C: - (int)bufferCapacity
Swift: public func bufferCapacity() -> Int32
C#: public virtual int bufferCapacity()

setBufferCapacity

设置 InputFrame 缓冲的容量。

C: void easyar_CameraDevice_setBufferCapacity(easyar_CameraDevice * This, int capacity)
C++17: void setBufferCapacity(int capacity)
Traditional C++: void setBufferCapacity(int capacity)
Java: public void setBufferCapacity(int capacity)
Kotlin: fun setBufferCapacity(capacity: Int): Unit
Objective-C: - (void)setBufferCapacity:(int)capacity
Swift: public func setBufferCapacity(_ capacity: Int32) -> Void
C#: public virtual void setBufferCapacity(int capacity)

inputFrameSource

InputFrame 输出端口。

C: void easyar_CameraDevice_inputFrameSource(easyar_CameraDevice * This, easyar_InputFrameSource * * Return)
C++17: std::shared_ptr<InputFrameSource> inputFrameSource()
Traditional C++: void inputFrameSource(InputFrameSource * * Return)
Java: public @Nonnull InputFrameSource inputFrameSource()
Kotlin: fun inputFrameSource(): InputFrameSource
Objective-C: - (easyar_InputFrameSource *)inputFrameSource
Swift: public func inputFrameSource() -> InputFrameSource
C#: public virtual InputFrameSource inputFrameSource()

setStateChangedCallback

设置状态变化回调以通知摄像机断开或被抢占的状态。只在Windows平台上有作用。

C: void easyar_CameraDevice_setStateChangedCallback(easyar_CameraDevice * This, easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromCameraState stateChangedCallback)
C++17: void setStateChangedCallback(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(CameraState)>> stateChangedCallback)
Traditional C++: void setStateChangedCallback(CallbackScheduler * callbackScheduler, OptionalOfFunctorOfVoidFromCameraState stateChangedCallback)
Java: public void setStateChangedCallback(@Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromCameraState stateChangedCallback)
Kotlin: fun setStateChangedCallback(callbackScheduler: CallbackScheduler, stateChangedCallback: FunctorOfVoidFromCameraState?): Unit
Objective-C: - (void)setStateChangedCallback:(easyar_CallbackScheduler *)callbackScheduler stateChangedCallback:(void (^)(easyar_CameraState))stateChangedCallback
Swift: public func setStateChangedCallback(_ callbackScheduler: CallbackScheduler, _ stateChangedCallback: ((CameraState) -> Void)?) -> Void
C#: public virtual void setStateChangedCallback(CallbackScheduler callbackScheduler, Optional<Action<CameraState>> stateChangedCallback)

requestPermissions

请求camera系统权限。你可以选择使用这个函数或自己申请权限。只在Android和iOS平台上有效,其他平台上的行为为直接调用回调通知权限已授权。应在UI线程调用该函数。

C: void easyar_CameraDevice_requestPermissions(easyar_CallbackScheduler * callbackScheduler, easyar_OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback)
C++17: static void requestPermissions(std::shared_ptr<CallbackScheduler> callbackScheduler, std::optional<std::function<void(PermissionStatus, std::string)>> permissionCallback)
Traditional C++: static void requestPermissions(CallbackScheduler * callbackScheduler, OptionalOfFunctorOfVoidFromPermissionStatusAndString permissionCallback)
Java: public static void requestPermissions(@Nonnull CallbackScheduler callbackScheduler, @Nullable FunctorOfVoidFromPermissionStatusAndString permissionCallback)
Kotlin: companion object fun requestPermissions(callbackScheduler: CallbackScheduler, permissionCallback: FunctorOfVoidFromPermissionStatusAndString?): Unit
Objective-C: + (void)requestPermissions:(easyar_CallbackScheduler *)callbackScheduler permissionCallback:(void (^)(easyar_PermissionStatus status, NSString * value))permissionCallback
Swift: public static func requestPermissions(_ callbackScheduler: CallbackScheduler, _ permissionCallback: ((PermissionStatus, String) -> Void)?) -> Void
C#: public static void requestPermissions(CallbackScheduler callbackScheduler, Optional<Action<PermissionStatus, string>> permissionCallback)

cameraCount

获得操作系统识别到的camera数量。

C: int easyar_CameraDevice_cameraCount(void)
C++17: static int cameraCount()
Traditional C++: static int cameraCount()
Java: public static int cameraCount()
Kotlin: companion object fun cameraCount(): Int
Objective-C: + (int)cameraCount
Swift: public static func cameraCount() -> Int32
C#: public static int cameraCount()

openWithIndex

按照camera索引打开camera设备。

C: bool easyar_CameraDevice_openWithIndex(easyar_CameraDevice * This, int cameraIndex)
C++17: bool openWithIndex(int cameraIndex)
Traditional C++: bool openWithIndex(int cameraIndex)
Java: public boolean openWithIndex(int cameraIndex)
Kotlin: fun openWithIndex(cameraIndex: Int): Boolean
Objective-C: - (bool)openWithIndex:(int)cameraIndex
Swift: public func openWithIndex(_ cameraIndex: Int32) -> Bool
C#: public virtual bool openWithIndex(int cameraIndex)

openWithType

(until 3.0.1)

按照camera类型打开camera设备。

C: bool easyar_CameraDevice_openWithType(easyar_CameraDevice * This, easyar_CameraDeviceType type)
C++17: bool openWithType(CameraDeviceType type)
Traditional C++: bool openWithType(CameraDeviceType type)
Java: public boolean openWithType(int type)
Kotlin: fun openWithType(type: Int): Boolean
Objective-C: - (bool)openWithType:(easyar_CameraDeviceType)type
Swift: public func openWithType(_ type: CameraDeviceType) -> Bool
C#: public virtual bool openWithType(CameraDeviceType type)

openWithSpecificType

(since 3.1.0)

按照精确的camera设备类型打开camera设备,如果没有匹配的类型则会返回false。在Mac上,camera类型无法判别。

C: bool easyar_CameraDevice_openWithSpecificType(easyar_CameraDevice * This, easyar_CameraDeviceType type)
C++17: bool openWithSpecificType(CameraDeviceType type)
Traditional C++: bool openWithSpecificType(CameraDeviceType type)
Java: public boolean openWithSpecificType(int type)
Kotlin: fun openWithSpecificType(type: Int): Boolean
Objective-C: - (bool)openWithSpecificType:(easyar_CameraDeviceType)type
Swift: public func openWithSpecificType(_ type: CameraDeviceType) -> Bool
C#: public virtual bool openWithSpecificType(CameraDeviceType type)

openWithPreferredType

(since 3.1.0)

按照camera设备类型打开camera设备,如果没有匹配的类型则会尝试打开第一个camera设备。

C: bool easyar_CameraDevice_openWithPreferredType(easyar_CameraDevice * This, easyar_CameraDeviceType type)
C++17: bool openWithPreferredType(CameraDeviceType type)
Traditional C++: bool openWithPreferredType(CameraDeviceType type)
Java: public boolean openWithPreferredType(int type)
Kotlin: fun openWithPreferredType(type: Int): Boolean
Objective-C: - (bool)openWithPreferredType:(easyar_CameraDeviceType)type
Swift: public func openWithPreferredType(_ type: CameraDeviceType) -> Bool
C#: public virtual bool openWithPreferredType(CameraDeviceType type)

start

开始采集数据。

C: bool easyar_CameraDevice_start(easyar_CameraDevice * This)
C++17: bool start()
Traditional C++: bool start()
Java: public boolean start()
Kotlin: fun start(): Boolean
Objective-C: - (bool)start
Swift: public func start() -> Bool
C#: public virtual bool start()

stop

停止采集数据。这个方法只会停止捕获图像,所有参数和连接将不会受到影响。

C: void easyar_CameraDevice_stop(easyar_CameraDevice * This)
C++17: void stop()
Traditional C++: void stop()
Java: public void stop()
Kotlin: fun stop(): Unit
Objective-C: - (void)stop
Swift: public func stop() -> Void
C#: public virtual void stop()

close

关闭camera。close之后不应继续使用。

C: void easyar_CameraDevice_close(easyar_CameraDevice * This)
C++17: void close()
Traditional C++: void close()
Java: public void close()
Kotlin: fun close(): Unit
Objective-C: - (void)close
Swift: public func close() -> Void
C#: public virtual void close()

index

(since 3.1.0)

cameras索引。

C: int easyar_CameraDevice_index(const easyar_CameraDevice * This)
C++17: int index()
Traditional C++: int index()
Java: public int index()
Kotlin: fun index(): Int
Objective-C: - (int)index
Swift: public func index() -> Int32
C#: public virtual int index()

type

camera类型。

在3.0.1和之前的版本,返回openWithType中填入的类型。

在3.1.0和之后的版本,返回camera的类型。

C: easyar_CameraDeviceType easyar_CameraDevice_type(const easyar_CameraDevice * This)
C++17: CameraDeviceType type()
Traditional C++: CameraDeviceType type()
Java: public int type()
Kotlin: fun type(): Int
Objective-C: - (easyar_CameraDeviceType)type
Swift: public func type() -> CameraDeviceType
C#: public virtual CameraDeviceType type()

cameraParameters

camera参数,包括图像大小、焦距、主点、camera类型和camera相对设备自然方向的旋转角度。在成功的open之后调用。

C: void easyar_CameraDevice_cameraParameters(easyar_CameraDevice * This, easyar_CameraParameters * * Return)
C++17: std::shared_ptr<CameraParameters> cameraParameters()
Traditional C++: void cameraParameters(CameraParameters * * Return)
Java: public @Nonnull CameraParameters cameraParameters()
Kotlin: fun cameraParameters(): CameraParameters
Objective-C: - (easyar_CameraParameters *)cameraParameters
Swift: public func cameraParameters() -> CameraParameters
C#: public virtual CameraParameters cameraParameters()

setCameraParameters

设置camera参数。在成功的open之后调用。

C: void easyar_CameraDevice_setCameraParameters(easyar_CameraDevice * This, easyar_CameraParameters * cameraParameters)
C++17: void setCameraParameters(std::shared_ptr<CameraParameters> cameraParameters)
Traditional C++: void setCameraParameters(CameraParameters * cameraParameters)
Java: public void setCameraParameters(@Nonnull CameraParameters cameraParameters)
Kotlin: fun setCameraParameters(cameraParameters: CameraParameters): Unit
Objective-C: - (void)setCameraParameters:(easyar_CameraParameters *)cameraParameters
Swift: public func setCameraParameters(_ cameraParameters: CameraParameters) -> Void
C#: public virtual void setCameraParameters(CameraParameters cameraParameters)

size

获取当前图像大小。在成功的open之后调用。

C: easyar_Vec2I easyar_CameraDevice_size(const easyar_CameraDevice * This)
C++17: Vec2I size()
Traditional C++: Vec2I size()
Java: public @Nonnull Vec2I size()
Kotlin: fun size(): Vec2I
Objective-C: - (easyar_Vec2I *)size
Swift: public func size() -> Vec2I
C#: public virtual Vec2I size()

supportedSizeCount

获取当前设备支持的所有图像大小的个数。在成功的open之后调用。

C: int easyar_CameraDevice_supportedSizeCount(const easyar_CameraDevice * This)
C++17: int supportedSizeCount()
Traditional C++: int supportedSizeCount()
Java: public int supportedSizeCount()
Kotlin: fun supportedSizeCount(): Int
Objective-C: - (int)supportedSizeCount
Swift: public func supportedSizeCount() -> Int32
C#: public virtual int supportedSizeCount()

supportedSize

获取当前设备支持的所有图像大小的第 index 个. 如果 index 超出范围则返回{0, 0}。在成功的open之后调用。

C: easyar_Vec2I easyar_CameraDevice_supportedSize(const easyar_CameraDevice * This, int index)
C++17: Vec2I supportedSize(int index)
Traditional C++: Vec2I supportedSize(int index)
Java: public @Nonnull Vec2I supportedSize(int index)
Kotlin: fun supportedSize(index: Int): Vec2I
Objective-C: - (easyar_Vec2I *)supportedSize:(int)index
Swift: public func supportedSize(_ index: Int32) -> Vec2I
C#: public virtual Vec2I supportedSize(int index)

setSize

设置当前图像大小。最接近设置值的可选值将被使用。可以使用size来获取实际的大小。在成功的open之后调用。设置size后frameRateRange可能会发生变化。

C: bool easyar_CameraDevice_setSize(easyar_CameraDevice * This, easyar_Vec2I size)
C++17: bool setSize(Vec2I size)
Traditional C++: bool setSize(Vec2I size)
Java: public boolean setSize(@Nonnull Vec2I size)
Kotlin: fun setSize(size: Vec2I): Boolean
Objective-C: - (bool)setSize:(easyar_Vec2I *)size
Swift: public func setSize(_ size: Vec2I) -> Bool
C#: public virtual bool setSize(Vec2I size)

supportedFrameRateRangeCount

获取当前设备支持的所有帧率范围的个数。在成功的open之后调用。

C: int easyar_CameraDevice_supportedFrameRateRangeCount(const easyar_CameraDevice * This)
C++17: int supportedFrameRateRangeCount()
Traditional C++: int supportedFrameRateRangeCount()
Java: public int supportedFrameRateRangeCount()
Kotlin: fun supportedFrameRateRangeCount(): Int
Objective-C: - (int)supportedFrameRateRangeCount
Swift: public func supportedFrameRateRangeCount() -> Int32
C#: public virtual int supportedFrameRateRangeCount()

supportedFrameRateRangeLower

获取当前设备支持的所有帧率范围的第 index 个的下界。在成功的open之后调用。

C: float easyar_CameraDevice_supportedFrameRateRangeLower(const easyar_CameraDevice * This, int index)
C++17: float supportedFrameRateRangeLower(int index)
Traditional C++: float supportedFrameRateRangeLower(int index)
Java: public float supportedFrameRateRangeLower(int index)
Kotlin: fun supportedFrameRateRangeLower(index: Int): Float
Objective-C: - (float)supportedFrameRateRangeLower:(int)index
Swift: public func supportedFrameRateRangeLower(_ index: Int32) -> Float
C#: public virtual float supportedFrameRateRangeLower(int index)

supportedFrameRateRangeUpper

获取当前设备支持的所有帧率范围的第 index 个的上界。在成功的open之后调用。

C: float easyar_CameraDevice_supportedFrameRateRangeUpper(const easyar_CameraDevice * This, int index)
C++17: float supportedFrameRateRangeUpper(int index)
Traditional C++: float supportedFrameRateRangeUpper(int index)
Java: public float supportedFrameRateRangeUpper(int index)
Kotlin: fun supportedFrameRateRangeUpper(index: Int): Float
Objective-C: - (float)supportedFrameRateRangeUpper:(int)index
Swift: public func supportedFrameRateRangeUpper(_ index: Int32) -> Float
C#: public virtual float supportedFrameRateRangeUpper(int index)

frameRateRange

获取当前设备的当前帧率范围的索引。在成功的open之后调用。

C: int easyar_CameraDevice_frameRateRange(const easyar_CameraDevice * This)
C++17: int frameRateRange()
Traditional C++: int frameRateRange()
Java: public int frameRateRange()
Kotlin: fun frameRateRange(): Int
Objective-C: - (int)frameRateRange
Swift: public func frameRateRange() -> Int32
C#: public virtual int frameRateRange()

setFrameRateRange

设置当前设备的当前帧率范围的索引。在成功的open之后调用。

C: bool easyar_CameraDevice_setFrameRateRange(easyar_CameraDevice * This, int index)
C++17: bool setFrameRateRange(int index)
Traditional C++: bool setFrameRateRange(int index)
Java: public boolean setFrameRateRange(int index)
Kotlin: fun setFrameRateRange(index: Int): Boolean
Objective-C: - (bool)setFrameRateRange:(int)index
Swift: public func setFrameRateRange(_ index: Int32) -> Bool
C#: public virtual bool setFrameRateRange(int index)

setFlashTorchMode

设置flash torch模式为on。在成功的open之后调用。

C: bool easyar_CameraDevice_setFlashTorchMode(easyar_CameraDevice * This, bool on)
C++17: bool setFlashTorchMode(bool on)
Traditional C++: bool setFlashTorchMode(bool on)
Java: public boolean setFlashTorchMode(boolean on)
Kotlin: fun setFlashTorchMode(on: Boolean): Boolean
Objective-C: - (bool)setFlashTorchMode:(bool)on
Swift: public func setFlashTorchMode(_ on: Bool) -> Bool
C#: public virtual bool setFlashTorchMode(bool on)

setFocusMode

设置对焦模式为focusMode。在成功的open之后调用。

C: bool easyar_CameraDevice_setFocusMode(easyar_CameraDevice * This, easyar_CameraDeviceFocusMode focusMode)
C++17: bool setFocusMode(CameraDeviceFocusMode focusMode)
Traditional C++: bool setFocusMode(CameraDeviceFocusMode focusMode)
Java: public boolean setFocusMode(int focusMode)
Kotlin: fun setFocusMode(focusMode: Int): Boolean
Objective-C: - (bool)setFocusMode:(easyar_CameraDeviceFocusMode)focusMode
Swift: public func setFocusMode(_ focusMode: CameraDeviceFocusMode) -> Bool
C#: public virtual bool setFocusMode(CameraDeviceFocusMode focusMode)

autoFocus

调用一次自动对焦。在start之后使用。仅在FocusMode为Normal或Macro时才能使用。

C: bool easyar_CameraDevice_autoFocus(easyar_CameraDevice * This)
C++17: bool autoFocus()
Traditional C++: bool autoFocus()
Java: public boolean autoFocus()
Kotlin: fun autoFocus(): Boolean
Objective-C: - (bool)autoFocus
Swift: public func autoFocus() -> Bool
C#: public virtual bool autoFocus()

setPresentProfile

(until 3.0.1)

设置图像预设模式。在成功的open之后调用。仅在Mac和iOS系统上可用。

在3.1.0和之后的版本中,可通过调用setSize来实现该函数的功能。

C: bool easyar_CameraDevice_setPresentProfile(easyar_CameraDevice * This, easyar_CameraDevicePresetProfile profile)
C++17: bool setPresentProfile(CameraDevicePresetProfile profile)
Traditional C++: bool setPresentProfile(CameraDevicePresetProfile profile)
Java: public boolean setPresentProfile(int profile)
Kotlin: fun setPresentProfile(profile: Int): Boolean
Objective-C: - (bool)setPresentProfile:(easyar_CameraDevicePresetProfile)profile
Swift: public func setPresentProfile(_ profile: CameraDevicePresetProfile) -> Bool
C#: public virtual bool setPresentProfile(CameraDevicePresetProfile profile)